﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Lib.Controls;
using System.Data;
using System.IO;
using System.Data.OleDb;

public partial class App_form_Import_ImportNhanSu : fpage
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
        ScriptManager.GetCurrent(this).Services.Add(new ServiceReference("~/Service/wht_nsd.svc"));
    }
    protected void AsyncFileUpload_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        if (AsyncFileUpload.HasFile)
        {
            try
            {
                string b_tenf = AsyncFileUpload.FileName.ToString();
                string tm = DateTime.Now.Year.ToString();
                string dd = Server.MapPath("~/VB/");
                dd = dd + tm;
                if (!Directory.Exists(dd))
                    Directory.CreateDirectory(dd);
                dd = dd + "/" + b_tenf;
                if (File.Exists(dd)) File.Delete(dd);
                AsyncFileUpload.PostedFile.SaveAs(dd);

                //string strPath = MapPath("~/VB/") + Path.GetFileName(e.filename);
                //AsyncFileUpload.SaveAs(strPath);
                UtilsExcel clsUtil = new UtilsExcel();
                DataTable dt_rs = clsUtil.GenerateExcelData(dd, new List<string>(new string[] { "HoTen", "NgaySinh", "Khoa" }));

                ht.FNS_NHANSU_NH(dt_rs);
            }
            catch (Exception ex)
            {
                
                log2File.LogExceptionToFile(ex);
            }
        }
    }
    
}